package com.liu;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
//开启断路器
@EnableCircuitBreaker
public class ProviderHystixApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProviderHystixApplication.class, args);
    }



    /**
     * Hystrix dashboard监控servlet
     * @return
     */
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean<HystrixMetricsStreamServlet> hystrixMetricsStreamServletServletRegistrationBean = new ServletRegistrationBean<>(new HystrixMetricsStreamServlet());
        hystrixMetricsStreamServletServletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
        return hystrixMetricsStreamServletServletRegistrationBean;
    }
}
